home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-desktop-9.10-i386-PL.iso / casper / filesystem.squashfs / usr / share / hplip / ui4 / aligndialog.py < prev    next >
Text File  |  2009-10-09  |  28KB  |  708 lines

  1. # -*- coding: utf-8 -*-
  2. #
  3. # (c) Copyright 2001-2008 Hewlett-Packard Development Company, L.P.
  4. #
  5. # This program is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; either version 2 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write to the Free Software
  17. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  18. #
  19. # Authors: Don Welch
  20. #
  21.  
  22. # StdLib
  23. import operator
  24.  
  25. # Local
  26. from base.g import *
  27. from base import device, utils, maint, status
  28. #from prnt import cups
  29. from base.codes import *
  30. from ui_utils import *
  31.  
  32. # Qt
  33. from PyQt4.QtCore import *
  34. from PyQt4.QtGui import *
  35.  
  36. # Ui
  37. from aligndialog_base import Ui_Dialog
  38.  
  39. PAGE_START = 0
  40. PAGE_LOAD_PAPER = 1
  41. PAGE_EDGE = 2
  42. PAGE_ALIGNMENT_NUMBER = 3
  43. PAGE_COLOR_ADJ = 4 # types 4, 5 & 7
  44. PAGE_LBOW = 5 # types 10 & 11
  45. PAGE_AIO = 6 # Place on scanner, ...
  46. PAGE_FRONT_PANEL = 7 # Use front panel menu
  47.  
  48. BUTTON_ALIGN = 0
  49. BUTTON_NEXT = 1
  50. BUTTON_FINISH = 2
  51.  
  52. ALIGN_TYPE_INITIAL = 1000
  53. ALIGN_TYPE_TEST = 1001
  54.  
  55. # xBow offset types
  56. ALIGN_TYPE_XBOW_OFFSET = 100
  57. ALIGN_TYPE_XBOW_BLACK_ONLY = ALIGN_TYPE_XBOW_OFFSET + AGENT_CONFIG_BLACK_ONLY
  58. ALIGN_TYPE_XBOW_PHOTO_ONLY = ALIGN_TYPE_XBOW_OFFSET + AGENT_CONFIG_PHOTO_ONLY
  59. ALIGN_TYPE_XBOW_COLOR_ONLY =  ALIGN_TYPE_XBOW_OFFSET + AGENT_CONFIG_COLOR_ONLY
  60. ALIGN_TYPE_XBOW_COLOR_AND_BLACK =  ALIGN_TYPE_XBOW_OFFSET + AGENT_CONFIG_COLOR_AND_BLACK
  61. ALIGN_TYPE_XBOW_COLOR_AND_PHOTO = ALIGN_TYPE_XBOW_OFFSET + AGENT_CONFIG_COLOR_AND_PHOTO
  62.  
  63.  
  64. def true():
  65.     return True
  66.  
  67.  
  68. class AlignDialog(QDialog, Ui_Dialog):
  69.     def __init__(self, parent, device_uri):
  70.         QDialog.__init__(self, parent)
  71.         self.device_uri = device_uri
  72.         self.mq = {}
  73.         self.step_max = 0
  74.         self.align_type = ALIGN_TYPE_INITIAL
  75.         self.step = 1
  76.         self.a, self.b, self.c, self.d, self.zca = 0, 0, 0, 0, 0
  77.         self.e, self.f, self.g = 0, 0, 0
  78.         self.num_inks = 0 # type 8
  79.         self.pattern = 0 # type 10
  80.         self.values = [] # type 10
  81.         self.abort = False
  82.         self.seq_index = 0
  83.  
  84.         self.max_steps = {
  85.             ALIGN_TYPE_UNSUPPORTED : 1,
  86.             ALIGN_TYPE_AUTO : 2,
  87.             ALIGN_TYPE_9XX : 7,
  88.             ALIGN_TYPE_8XX : 7,
  89.             ALIGN_TYPE_LIDIL_0_3_8 : 0,
  90.             ALIGN_TYPE_LIDIL_0_4_3 : 0,
  91.             ALIGN_TYPE_LIDIL_AIO : 3,
  92.             ALIGN_TYPE_LIDIL_VIP : 0,
  93.             ALIGN_TYPE_DESKJET_450 : 0,
  94.             ALIGN_TYPE_9XX_NO_EDGE_ALIGN : 6,
  95.             ALIGN_TYPE_LBOW : 0,
  96.             ALIGN_TYPE_LIDIL_0_5_4 : 0,
  97.             ALIGN_TYPE_OJ_PRO : 0,
  98.             ALIGN_TYPE_TEST : 0,
  99.             ALIGN_TYPE_AIO : 3,
  100.             ALIGN_TYPE_LIDIL_DJ_D1600: 0,
  101.             }
  102.  
  103.         self.seq = { # (func|method, tuple of params|None)
  104.             ALIGN_TYPE_TEST : [ # testing only
  105.                                (self.showColorAdjustPage, ('F', 21)),
  106.                                (self.endColorAdjustPage, ('F',)),
  107.                                (self.showColorAdjustPage, ('G', 11)),
  108.                                (self.endColorAdjustPage, ('G',)),
  109.                                (self.close, None),
  110.                             ],
  111.  
  112.             ALIGN_TYPE_INITIAL : [ # (used when starting up and align-type isn't known)
  113.                                (self.showStartPage, None),
  114.                                (self.endStartPage, None), # switch to a valid align-type here
  115.                             ],
  116.  
  117.             ALIGN_TYPE_UNSUPPORTED : [ # -1
  118.                                 (self.showFrontPanelPage, None),
  119.                                 (self.endFronPanelPage, None),
  120.                                 (self.close, None),
  121.                             ],
  122.  
  123. #            ALIGN_TYPE_NONE : [ # 0
  124. #                               (self.close, None)
  125. #                            ],
  126.  
  127.             ALIGN_TYPE_AUTO : [ # 1
  128.                                (self.showLoadPaperPage, None),
  129.                                (maint.AlignType1PML, (lambda : self.dev, lambda: true)),
  130.                                (self.closeAll, None),
  131.                                (self.close, None),
  132.                             ],
  133.  
  134.             ALIGN_TYPE_8XX : [ # 2
  135.                                 (self.checkType2PenConfig, None),
  136.                                 (self.showLoadPaperPage, None),
  137.                                 (maint.alignType2Phase1, (lambda: self.dev,)),
  138.                                 (self.showAlignmentNumberPage, ('A', 'h', 'kc', 2, 11)),
  139.                                 (self.endAlignmentNumberPage, ('A',)),
  140.                                 (self.showAlignmentNumberPage, ('B', 'v', 'kc', 2, 11)),
  141.                                 (self.endAlignmentNumberPage, ('B',)),
  142.                                 (self.showAlignmentNumberPage, ('C', 'v', 'kc', 2, 5)),
  143.                                 (self.endAlignmentNumberPage, ('C',)),
  144.                                 (self.showAlignmentNumberPage, ('D', 'v', 'c', 2, 5)),
  145.                                 (self.endAlignmentNumberPage, ('D',)),
  146.                                 (self.setAlignButton, (BUTTON_ALIGN,)),
  147.                                 (self.showLoadPaperPage, (lambda: True,)),
  148.                                 (maint.alignType2Phase2, (lambda: self.dev, lambda: self.a, lambda: self.b,
  149.                                                           lambda: self.c, lambda: self.d)),
  150.                                 (self.close, None),
  151.                               ],
  152.  
  153.             ALIGN_TYPE_9XX : [  # 3
  154.                                 (self.showLoadPaperPage, None),
  155.                                 (self.showAlignmentNumberPage, ('A', 'h', 'kc', 2, 11)),
  156.                                 (self.endAlignmentNumberPage, ('A',)),
  157.                                 (self.showAlignmentNumberPage, ('B', 'v', 'kc', 2, 11)),
  158.                                 (self.endAlignmentNumberPage, ('B',)),
  159.                                 (self.showAlignmentNumberPage, ('C', 'v', 'k', 2, 11)),
  160.                                 (self.endAlignmentNumberPage, ('C',)),
  161.                                 (self.setAlignButton, (BUTTON_ALIGN,)),
  162.                                 (self.showAlignmentNumberPage, ('D', 'v', 'kc', 2, 11)),
  163.                                 (self.endAlignmentNumberPage, ('D',)),
  164.                                 (maint.alignType3Phase2, (lambda: self.dev, lambda: self.a, lambda: self.b,
  165.                                                           lambda: self.c, lambda: self.d)),
  166.                                 (maint.alignType3Phase3, (lambda: self.dev,)),
  167.                                 (self.showPageEdgePage, None),
  168.                                 (self.endPageEdgePage, None),
  169.                                 (maint.alignType3Phase4, (lambda: self.dev, lambda: self.zca)),
  170.                                 (self.close, None),
  171.                              ],
  172.  
  173.             ALIGN_TYPE_LIDIL_0_3_8 : [ # 4
  174.                                 (self.showLoadPaperPage, None),
  175.                                 (self.setPenConfig, None),
  176.                                 (maint.alignType4Phase1, (lambda: self.dev,)),
  177.                                 (self.setXBow, None),
  178.                                 # switches to offset align_type here
  179.                             ],
  180.  
  181.             ALIGN_TYPE_LIDIL_0_4_3 : [ # 5
  182.                                 (self.showLoadPaperPage, None),
  183.                                 (self.setPenConfig, None),
  184.                                 (maint.alignType5Phase1, (lambda: self.dev,)),
  185.                                 (self.showPageEdgePage, ('A',)),
  186.                                 (self.endPageEdgePage, None),
  187.                                 (self.setXBow, None),
  188.                                 # switches to offset align_type here
  189.                             ],
  190.  
  191.             ALIGN_TYPE_LIDIL_VIP : [ # 7
  192.                                 (self.showLoadPaperPage, None),
  193.                                 (self.setPenConfig, None),
  194.                                 (maint.alignType7Phase1, (lambda: self.dev,)),
  195.                                 (self.showPageEdgePage, ('A',)),
  196.                                 (self.endPageEdgePage, None),
  197.                                 (self.setXBow, None),
  198.                                 # switches to offset align_type here (next 5 types)
  199.                             ],
  200.  
  201.             # xBow offset alignment type
  202.             ALIGN_TYPE_XBOW_BLACK_ONLY : [ # 4, 5 & 7
  203.                             (self.showAlignmentNumberPage, ('B', 'v', 'k', 2, 11)),
  204.                             (self.endAlignmentNumberPage, ('B',)),
  205.                             (self.setXBowValues, None),
  206.                             (self.close, None),
  207.                             ],
  208.  
  209.             # xBow offset alignment type
  210.             ALIGN_TYPE_XBOW_PHOTO_ONLY : [ # 4, 5 & 7
  211.                             (self.showAlignmentNumberPage, ('B', 'v', 'k', 2, 11)),
  212.                             (self.endAlignmentNumberPage, ('B',)),
  213.                             (self.setXBowValues, None),
  214.                             (self.close, None),
  215.                             ],
  216.  
  217.             # xBow offset alignment type
  218.             ALIGN_TYPE_XBOW_COLOR_ONLY : [ # 4, 5 & 7
  219.                             (self.showAlignmentNumberPage, ('B', 'v', 'kc', 2, 11)),
  220.                             (self.endAlignmentNumberPage, ('B',)),
  221.                             (self.setXBowValues, None),
  222.                             (self.close, None),
  223.                             ],
  224.  
  225.             # xBow offset alignment type
  226.             ALIGN_TYPE_XBOW_COLOR_AND_BLACK : [ # 4, 5 & 7
  227.                             (self.showAlignmentNumberPage, ('B', 'h', 'kc', 2, 17)),
  228.                             (self.endAlignmentNumberPage, ('B',)),
  229.                             (self.showAlignmentNumberPage, ('C', 'v', 'kc', 2, 17)),
  230.                             (self.endAlignmentNumberPage, ('C',)),
  231.                             (self.showAlignmentNumberPage, ('D', 'v', 'k', 2, 11)),
  232.                             (self.endAlignmentNumberPage, ('D',)),
  233.                             (self.showAlignmentNumberPage, ('E', 'v', 'kc', 2, 11)),
  234.                             (self.endAlignmentNumberPage, ('E',)),
  235.                             (self.setXBowValues, None),
  236.                             (self.close, None),
  237.                             ],
  238.  
  239.             # xBow offset alignment type
  240.             ALIGN_TYPE_XBOW_COLOR_AND_PHOTO : [ # 4, 5 & 7
  241.                             (self.showAlignmentNumberPage, ('B', 'h', 'kc', 2, 17)),
  242.                             (self.endAlignmentNumberPage, ('B',)),
  243.                             (self.showAlignmentNumberPage, ('C', 'v', 'kc', 2, 17)),
  244.                             (self.endAlignmentNumberPage, ('C',)),
  245.                             (self.showAlignmentNumberPage, ('D', 'v', 'k', 2, 11)),
  246.                             (self.endAlignmentNumberPage, ('D',)),
  247.                             (self.showAlignmentNumberPage, ('E', 'v', 'kc', 2, 11)),
  248.                             (self.endAlignmentNumberPage, ('E',)),
  249.                             (self.showColorAdjustPage, ('F', 21)),
  250.                             (self.endColorAdjustPage, ('F',)),
  251.                             (self.showColorAdjustPage, ('G', 21)),
  252.                             (self.endColorAdjustPage, ('G',)),
  253.                             (self.setXBowValues, None),
  254.                             (self.close, None),
  255.                             ],
  256.  
  257.             ALIGN_TYPE_LIDIL_AIO : [ # 6 (semi-auto)
  258.                                 (self.showLoadPaperPage, None),
  259.                                 (maint.alignType6Phase1, (lambda: self.dev,)),
  260.                                 (self.setAlignButton, (BUTTON_FINISH,)),
  261.                                 (self.showAioPage, None),
  262.                                 (self.close, None),
  263.                             ],
  264.  
  265.             ALIGN_TYPE_DESKJET_450 : [ # 8
  266.                                 (self.showLoadPaperPage, None),
  267.                                 (self.alignType8Phase1, None), # sets num_inks
  268.                                 (self.showAlignmentNumberPage, ('A', 'v', 'k', 3, 9)),
  269.                                 (self.endAlignmentNumberPage, ('A',)),
  270.                                 (self.showAlignmentNumberPage, ('B', 'v', 'c', 3, 9)),
  271.                                 (self.endAlignmentNumberPage, ('B',)),
  272.                                 (self.showAlignmentNumberPage, ('C', 'v', 'kc', 3, 9)),
  273.                                 (self.endAlignmentNumberPage, ('C',)),
  274.                                 (self.setAlignButton, (BUTTON_ALIGN,)),
  275.                                 (self.showAlignmentNumberPage, ('D', 'h', 'kc', 3, 9)),
  276.                                 (self.endAlignmentNumberPage, ('D',)),
  277.                                 (maint.alignType3Phase2, (lambda: self.dev, lambda: self.num_inks, lambda: self.a,
  278.                                                           lambda: self.b, lambda: self.c, lambda: self.d)),
  279.                                 (self.close, None),
  280.                             ],
  281.  
  282.             ALIGN_TYPE_9XX_NO_EDGE_ALIGN : [  # 9
  283.                                 (self.showLoadPaperPage, None),
  284.                                 (self.showAlignmentNumberPage, ('A', 'h', 'kc', 2, 11)),
  285.                                 (self.endAlignmentNumberPage, ('A',)),
  286.                                 (self.showAlignmentNumberPage, ('B', 'v', 'kc', 2, 11)),
  287.                                 (self.endAlignmentNumberPage, ('B',)),
  288.                                 (self.showAlignmentNumberPage, ('C', 'v', 'k', 2, 11)),
  289.                                 (self.endAlignmentNumberPage, ('C',)),
  290.                                 (self.setAlignButton, (BUTTON_ALIGN,)),
  291.                                 (self.showAlignmentNumberPage, ('D', 'v', 'kc', 2, 11)),
  292.                                 (self.endAlignmentNumberPage, ('D',)),
  293.                                 (maint.alignType3Phase2, (lambda: self.dev, lambda: self.a, lambda: self.b,
  294.                                                           lambda: self.c, lambda: self.d)),
  295.                                 (self.close, None),
  296.                             ],
  297.  
  298.             ALIGN_TYPE_LBOW : [ # 10
  299.                                (self.showLoadPaperPage, None),
  300.                                (maint.alignType10Phase1, (lambda: self.dev,)),
  301.                                (self.setAlignButton, (BUTTON_ALIGN,)),
  302.                                (self.showLBowPage, (lambda: self.pattern,)),
  303.                                (self.endLBowPage, None), # sets values
  304.                                (maint.alignType10Phase2, (lambda: self.dev, lambda: self.values,
  305.                                                           lambda: self.pattern)),
  306.                                (self.setAlignButton, (BUTTON_FINISH,)),
  307.                                (self.showLoadPaperPage, (lambda: True,)),
  308.                                (maint.alignType10Phase3, (lambda: self.dev,)),
  309.                                (self.close, None),
  310.                             ],
  311.  
  312.             ALIGN_TYPE_LIDIL_0_5_4 : [ # 11
  313.                                (self.showLoadPaperPage, None),
  314.                                (maint.alignType11Phase1, (lambda: self.dev,)),
  315.                                (self.setAlignButton, (BUTTON_ALIGN,)),
  316.                                (self.showLBowPage, (lambda: self.pattern,)),
  317.                                (self.endLBowPage, None), # sets values
  318.                                (maint.alignType11Phase2, (lambda: self.dev, lambda: self.values,
  319.                                                           lambda: self.pattern, lambda: self.dev.pen_config)),
  320.                                (self.setAlignButton, (BUTTON_FINISH,)),
  321.                                (self.showLoadPaperPage, (lambda: True,)),
  322.                                (maint.alignType11Phase3, (lambda: self.dev,)),
  323.                                (self.close, None),
  324.                             ],
  325.  
  326.             ALIGN_TYPE_OJ_PRO : [ # 12
  327.                                 (self.showLoadPaperPage, None),
  328.                                 (maint.AlignType12, (lambda : self.dev, lambda: true)),
  329.                                 (self.close, None),
  330.                             ],
  331.  
  332.             ALIGN_TYPE_AIO : [ #13
  333.                               (self.showLoadPaperPage, None),
  334.                               (maint.alignType13Phase1, (lambda: self.dev,)),
  335.                               (self.setAlignButton, (BUTTON_FINISH,)),
  336.                               (self.showAioPage, None),
  337.                               (self.close, None),
  338.                             ],
  339.  
  340.             ALIGN_TYPE_LIDIL_DJ_D1600 : [ # 14
  341.                                (self.showLoadPaperPage, None),
  342.                                (maint.alignType14Phase1, (lambda: self.dev,)),
  343.                                (self.setAlignButton, (BUTTON_ALIGN,)),
  344.                                (self.showLBowPage, (lambda: self.pattern,)),
  345.                                (self.endLBowPage, None), # sets values
  346.                                (maint.alignType14Phase2, (lambda: self.dev, lambda: self.values,
  347.                                                           lambda: self.pattern, lambda: self.dev.pen_config)),
  348.                                (self.setAlignButton, (BUTTON_FINISH,)),
  349.                                (self.showLoadPaperPage, (lambda: True,)),
  350.                                (maint.alignType14Phase3, (lambda: self.dev,)),
  351.                                (self.close, None),
  352.                             ],
  353.  
  354.             }
  355.  
  356.         self.setupUi(self)
  357.         self.initUi()
  358.  
  359.         QTimer.singleShot(0, self.nextSequence)
  360.  
  361.  
  362.     def initUi(self):
  363.         # connect signals/slots
  364.         self.connect(self.CancelButton, SIGNAL("clicked()"), self.CancelButton_clicked)
  365.         self.connect(self.NextButton, SIGNAL("clicked()"), self.NextButton_clicked)
  366.         #self.connect(self.BackButton, SIGNAL("clicked()"), self.BackButton_clicked)
  367.         self.connect(self.DeviceComboBox, SIGNAL("DeviceUriComboBox_noDevices"), self.DeviceUriComboBox_noDevices)
  368.         self.connect(self.DeviceComboBox, SIGNAL("DeviceUriComboBox_currentChanged"), self.DeviceUriComboBox_currentChanged)
  369.         self.DeviceComboBox.setFilter({'align-type': (operator.gt, 0)})
  370.  
  371.         # Application icon
  372.         self.setWindowIcon(QIcon(load_pixmap('hp_logo', '128x128')))
  373.  
  374.         if self.device_uri:
  375.             self.DeviceComboBox.setInitialDevice(self.device_uri)
  376.  
  377.  
  378.     def DeviceUriComboBox_noDevices(self):
  379.         FailureUI(self, self.__tr("<b>No devices that support print cartridge alignment found.</b><p>Click <i>OK</i> to exit.</p>"))
  380.         self.close()
  381.  
  382.  
  383.     def DeviceUriComboBox_currentChanged(self, device_uri):
  384.         self.device_uri = device_uri
  385.  
  386.  
  387.     def CancelButton_clicked(self):
  388.         self.close()
  389.  
  390.  
  391.     def NextButton_clicked(self):
  392.         self.nextSequence()
  393.  
  394.  
  395.     def nextSequence(self):
  396.         while True:
  397.             try:
  398.                 seq, params = self.seq[self.align_type][self.seq_index]
  399.             except IndexError:
  400.                 break
  401.  
  402.             if seq is None:
  403.                 self.seq_index += 1
  404.                 continue
  405.  
  406.             self.new_page = False
  407.  
  408.             t = []
  409.             if params is not None:
  410.                 for p in params:
  411.                     try:
  412.                         t.append(p())
  413.                     except:
  414.                         t.append(p)
  415.  
  416.             try:
  417.                 log.debug("%s(%s)" % (seq.func_name, ','.join([repr(x) for x in t])))
  418.             except AttributeError:
  419.                 pass
  420.  
  421.             try:
  422.                 seq(*t)
  423.             except Error:
  424.                 CheckDeviceUI(self)
  425.                 break
  426.  
  427.             self.seq_index += 1
  428.  
  429.             if self.new_page:
  430.                 break
  431.  
  432.             if self.abort:
  433.                 self.close()
  434.  
  435.  
  436.  
  437.     def showStartPage(self):
  438. #       self.BackButton.setEnabled(False)
  439.         num_devices = self.DeviceComboBox.setDevices()
  440.  
  441.         if num_devices == 1:
  442.             self.skipPage()
  443.             return
  444.  
  445.         self.DeviceComboBox.updateUi()
  446.         self.displayPage(PAGE_START)
  447.  
  448.  
  449.     def endStartPage(self):
  450.         self.mq = device.queryModelByURI(self.device_uri)
  451.         self.align_type = self.mq.get('align-type', ALIGN_TYPE_NONE)
  452.         self.seq_index = -1
  453.  
  454.         #self.align_type = ALIGN_TYPE_TEST# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  455.  
  456.         log.debug("align-type=%d" % self.align_type)
  457.         self.step_max = self.max_steps[self.align_type]
  458.  
  459.         try:
  460.             self.dev = device.Device(self.device_uri)
  461.         except Error:
  462.             CheckDeviceUI(self)
  463.             return
  464.  
  465.  
  466.     def showLoadPaperPage(self, finish=False):
  467.         if finish:
  468.             self.LoadPaper.button_name = self.__tr("Finish >")
  469.         self.LoadPaper.updateUi()
  470.         self.displayPage(PAGE_LOAD_PAPER)
  471.  
  472.  
  473.     def endLoadPaperPage(self):
  474.         pass
  475.  
  476.  
  477.     def showAlignmentNumberPage(self, line_id, orientation, colors, line_count, choice_count):
  478.         # line_id: 'A', 'B', etc.
  479.         # orientation: 'v' or 'h'
  480.         # colors: 'k' or 'c' or 'kc'
  481.         # line_count: 2 or 3
  482.         # choice_count: 5, 7, 9, 11, etc. (odd)
  483.         self.AlignmentNumberTitle.setText(self.__tr("Choose the set of lines in group %1 where the line segments are <b>best</b> aligned.").arg(line_id))
  484.         self.AlignmentNumberIcon.setPixmap(load_pixmap('%s-%s-%d' % (orientation, colors, line_count), 'other'))
  485.         self.AlignmentNumberComboBox.clear()
  486.  
  487.         for x in range(choice_count):
  488.             self.AlignmentNumberComboBox.addItem(QString("%1%2").arg(line_id).arg(x+1))
  489.  
  490.         self.displayPage(PAGE_ALIGNMENT_NUMBER)
  491.  
  492.  
  493.     def endAlignmentNumberPage(self, line_id):
  494.         v = int(str(self.AlignmentNumberComboBox.currentText())[1:])
  495.  
  496.         if line_id == 'A':
  497.             self.a = v
  498.             log.debug("A=%d" % v)
  499.  
  500.         elif line_id == 'B':
  501.             self.b = v
  502.             log.debug("B=%d" % v)
  503.  
  504.         elif line_id == 'C':
  505.             self.c = v
  506.             log.debug("C=%d" % v)
  507.  
  508.         elif line_id == 'D':
  509.             self.d = v
  510.             log.debug("D=%d" % v)
  511.  
  512.  
  513.     def showPageEdgePage(self, prefix=None, count=13):
  514.         self.PageEdgeTitle.setText(self.__tr("Choose the <b>numbered arrow</b> that <b>best </b>marks the edge of the paper."))
  515.         self.PageEdgeIcon.setPixmap(load_pixmap('zca.png', 'other'))
  516.  
  517.         self.PageEdgeComboBox.clear()
  518.         for x in range(count):
  519.             if prefix is None:
  520.                 self.PageEdgeComboBox.addItem(QString("%1").arg(x+1))
  521.             else:
  522.                 self.PageEdgeComboBox.addItem(QString("%1%2").arg(prefix).arg(x+1)) # for xBow
  523.  
  524.         self.displayPage(PAGE_EDGE)
  525.  
  526.  
  527.     def endPageEdgePage(self):
  528.         v = int(str(self.PageEdgeComboBox.currentText())[1:])
  529.         self.zca = v
  530.         log.debug("ZCA=%d" % v)
  531.  
  532.  
  533.     def showLBowPage(self, pattern):
  534.         self.LBowIcon.setPixmap(load_pixmap('align10', 'other'))
  535.  
  536.         if self.align_type == ALIGN_TYPE_LBOW:
  537.             pattern = maint.alignType10SetPattern(self.dev)
  538.  
  539.         elif self.align_type == ALIGN_TYPE_LIDIL_DJ_D1600:
  540.             pattern = maint.alignType14SetPattern(self.dev)
  541.  
  542.         else: # ALIGN_TYPE_LIDIL_0_5_4
  543.             pattern = maint.alignType11SetPattern(self.dev)
  544.  
  545.         if pattern is None:
  546.             log.error("Invalid pattern!")
  547.             # TODO: ...
  548.  
  549.         self.controls = maint.align10and11and14Controls(pattern, self.align_type)
  550.         keys = self.controls.keys()
  551.         keys.sort()
  552.         max_line = 'A'
  553.         for line in keys:
  554.             if self.controls[line][0]:
  555.                 max_line = line
  556.             else:
  557.                 break
  558.  
  559.         self.LBowTitle.setText(self.__tr("For each row A - %1, select the label representing the box in which in the inner lines are the <b>least</b> visible.").arg(max_line))
  560.  
  561.         for line in self.controls:
  562.             if not self.controls[line][0]:
  563.                 eval('self.%sComboBox.setEnabled(False)' % line.lower())
  564.             else:
  565.                 for x in range(self.controls[line][1]):
  566.                     eval('self.%sComboBox.addItem("%s%d")' % (line.lower(), line, x + 1))
  567.  
  568.         self.displayPage(PAGE_LBOW)
  569.  
  570.  
  571.  
  572.     def endLBowPage(self):
  573.         self.values = []
  574.         controls = self.controls.keys()
  575.         controls.sort()
  576.  
  577.         for line in controls:
  578.             if not self.controls[line][0]:
  579.                 self.values.append(0)
  580.             else:
  581.                 exec('selected = unicode(self.%sComboBox.currentText())' % line.lower())
  582.                 try:
  583.                     selected = int(selected[1:])
  584.                 except ValueError:
  585.                     selected = 0
  586.  
  587.                 self.values.append(selected)
  588.  
  589.  
  590.     def showAioPage(self):
  591.         self.AioIcon.setPixmap(load_pixmap('aio_align', 'other'))
  592.         self.displayPage(PAGE_AIO)
  593.  
  594.  
  595.     def endAioPage(self):
  596.         pass
  597.  
  598.  
  599.     def showColorAdjustPage(self, line_id, count=21):
  600.         self.ColorAdjustComboBox.clear()
  601.         self.ColorAdjustIcon.setPixmap(load_pixmap('color_adj', 'other'))
  602.         self.ColorAdjustLabel.setText(self.__tr("Line %1:").arg(line_id))
  603.  
  604.         for x in range(count):
  605.             self.ColorAdjustComboBox.addItem(QString("%1%2").arg(line_id).arg(x+1))
  606.  
  607.         self.displayPage(PAGE_COLOR_ADJ)
  608.  
  609.  
  610.     def endColorAdjustPage(self, line_id):
  611.         v = int(str(self.ColorAdjustComboBox.currentText())[1:])
  612.  
  613.         if line_id == 'F':
  614.             self.f = v
  615.             log.debug("F=%d" % v)
  616.  
  617.         elif line_id == 'G':
  618.             self.g = v
  619.             log.debug("G=%d" % v)
  620.  
  621.  
  622.     def showFrontPanelPage(self):
  623. #       self.BackButton.setEnabled(False)
  624.         self.setAlignButton(BUTTON_FINISH)
  625.         self.displayPage(PAGE_FRONT_PANEL)
  626.  
  627.  
  628.     def endFronPanelPage(self):
  629.         pass
  630.  
  631.     #
  632.     #  ALIGN-TYPE SPECIFIC
  633.     #
  634.  
  635.     def checkType2PenConfig(self):
  636.         pass
  637.         # TODO: set abort if problem
  638.  
  639.  
  640.     def alignType8Phase1(self):
  641.         self.num_inks = maint.alignType8Phase1(self.dev)
  642.  
  643.  
  644.     def setXBow(self):
  645.         # TODO: set abort if invalid pen config
  646.         self.real_align_type = self.align_type
  647.         self.align_type = ALIGN_TYPE_XBOW_OFFSET + self.dev.pen_config
  648.         self.seq_index = -1
  649.  
  650.  
  651.     def setXBowValues(self):
  652.         if self.real_align_type ==  ALIGN_TYPE_LIDIL_0_3_8:
  653.             maint.alignType4Phase2(self.dev, self.zca, self.b, self.c, self.d, self.e)
  654.             maint.alignType4Phase3(self.dev)
  655.  
  656.         elif self.real_align_type == ALIGN_TYPE_LIDIL_0_4_3:
  657.             maint.alignType5Phase2(self.dev, self.zca, self.b, self.c, self.d, self.e, self.f, self.g)
  658.             maint.alignType5Phase3(self.dev)
  659.  
  660.         elif self.real_align_type == ALIGN_TYPE_LIDIL_VIP:
  661.             maint.alignType7Phase2(self.dev, self.zca, self.b, self.c, self.d, self.e, self.f, self.g)
  662.             maint.alignType7Phase3(self.dev)
  663.  
  664.  
  665.     #
  666.     # Misc
  667.     #
  668.  
  669.     def displayPage(self, page):
  670.         self.updateStepText(self.step)
  671.         self.step += 1
  672.         self.new_page = True
  673.         self.StackedWidget.setCurrentIndex(page)
  674.  
  675.  
  676.     def skipPage(self):
  677.         self.step += 1
  678.         self.new_page = False
  679.  
  680.  
  681.     def updateStepText(self, p=None):
  682.         if p is None or not self.step_max:
  683.             self.StepText.setText(QString(""))
  684.         else:
  685.             self.StepText.setText(self.__tr("Step %1 of %2").arg(p).arg(self.step_max))
  686.  
  687.  
  688.     def setAlignButton(self, typ=BUTTON_ALIGN):
  689.         if typ == BUTTON_ALIGN:
  690.             self.NextButton.setText(self.__tr("Align"))
  691.         elif typ == BUTTON_NEXT:
  692.             self.NextButton.setText(self.__tr("Next >"))
  693.         elif typ == BUTTON_FINISH:
  694.             self.NextButton.setText(self.__tr("Finish"))
  695.  
  696.  
  697.     def setPenConfig(self):
  698.         self.dev.pen_config = status.getPenConfiguration(self.dev.getStatusFromDeviceID())
  699.  
  700.  
  701.     def closeAll(self):
  702.         if self.dev is not None:
  703.             self.dev.close()
  704.  
  705.  
  706.     def __tr(self,s,c = None):
  707.         return qApp.translate("AlignDialog",s,c)
  708.